home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / shbrowse / form1.frm next >
Text File  |  1998-07-06  |  4KB  |  122 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Example of how to use SHBrowse.dll"
  7.    ClientHeight    =   876
  8.    ClientLeft      =   1080
  9.    ClientTop       =   1476
  10.    ClientWidth     =   5664
  11.    BeginProperty Font 
  12.       Name            =   "MS Sans Serif"
  13.       Size            =   7.8
  14.       Charset         =   0
  15.       Weight          =   700
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    ForeColor       =   &H80000008&
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    PaletteMode     =   1  'UseZOrder
  25.    ScaleHeight     =   876
  26.    ScaleWidth      =   5664
  27.    StartUpPosition =   2  'CenterScreen
  28.    Begin VB.CommandButton Command3 
  29.       Appearance      =   0  'Flat
  30.       BackColor       =   &H80000005&
  31.       Caption         =   "Browse"
  32.       Default         =   -1  'True
  33.       BeginProperty Font 
  34.          Name            =   "MS Sans Serif"
  35.          Size            =   7.8
  36.          Charset         =   0
  37.          Weight          =   400
  38.          Underline       =   0   'False
  39.          Italic          =   0   'False
  40.          Strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   360
  43.       Left            =   4284
  44.       TabIndex        =   0
  45.       Top             =   252
  46.       Width           =   1215
  47.    End
  48.    Begin VB.Label Label1 
  49.       BeginProperty Font 
  50.          Name            =   "MS Sans Serif"
  51.          Size            =   7.8
  52.          Charset         =   0
  53.          Weight          =   400
  54.          Underline       =   0   'False
  55.          Italic          =   0   'False
  56.          Strikethrough   =   0   'False
  57.       EndProperty
  58.       Height          =   336
  59.       Left            =   168
  60.       TabIndex        =   1
  61.       Top             =   264
  62.       Width           =   3996
  63.    End
  64. End
  65. Attribute VB_Name = "Form1"
  66. Attribute VB_GlobalNameSpace = False
  67. Attribute VB_Creatable = False
  68. Attribute VB_PredeclaredId = True
  69. Attribute VB_Exposed = False
  70. Option Explicit
  71.  
  72. '----------------------------------------------------------
  73. ' GetFolder
  74. '-----------
  75. '   hWnd            The window handle of the calling window
  76. '   DlgCaption      The caption of the label that appears just above the Tree control
  77. '   SelectedPath    The String variable that will return the selected path - if any.
  78. '                   (The string space must be allocated by the calling program)
  79. '
  80. Private Declare Function GetFolder Lib "SHBrowse.dll" (ByVal hwnd As Long, ByVal DlgCaption As String, ByVal SelectedPath As String) As Long
  81. Private Sub Command2_Click()
  82.     End
  83. End Sub
  84.  
  85. Private Sub Command3_Click()
  86.  
  87.     Dim lRet As Long
  88.     Dim DlgCaption As String
  89.     Dim S2 As String
  90.     Dim iPos As Integer
  91.     
  92. '   Use a fixed length string
  93.     Dim S As String * 256
  94.     
  95. '   Allocate space for the string now. The DLL expects the
  96. '   memory to have already been allocated for the string
  97. '   that will return the path selected on the Browse Dlg.
  98.     S = String(256, 0)
  99.     
  100. '   Set the caption that will appear just above the Tree.
  101.     DlgCaption = "Select New Folder"
  102.     
  103. '   Get the new folder
  104.     lRet = GetFolder(Me.hwnd, DlgCaption, S)
  105.     
  106.     iPos = InStr(1, S, Chr(0))
  107.     S2 = Left$(S, iPos - 1)
  108.     'MsgBox "Return path is " & S2
  109.     Label1.Caption = S2
  110.  
  111. End Sub
  112.  
  113.  
  114. Private Sub Form_Load()
  115.  
  116.     ChDrive App.Path
  117.     ChDir App.Path
  118.     
  119. End Sub
  120.  
  121.  
  122.